package com.h3c.ptability.controller;

import com.alibaba.fastjson.JSONObject;
import com.h3c.ptability.client.LogDataFeignClient;
import com.h3c.ptability.entity.SdAuthChgLog;
import com.h3c.ptability.entity.SdFileOperLog;
import com.h3c.ptability.entity.SdOperLog;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@Api(tags = " ptlog 接口")
@CrossOrigin
@Slf4j
@RestController
@RequestMapping(value = "/ptlog")
public class PtlogController {

    @Autowired
    private LogDataFeignClient logDataFeignClient;

    @RequestMapping(value = "/querySdOperLog", method = RequestMethod.GET)
    public ResponseEntity<JSONObject> querySdOperLog(@ModelAttribute SdOperLog paramsDTO,
                                        @RequestParam(name = "startTime") String startTime,
                                        @RequestParam(name = "endTime") String endTime,
                                        @RequestParam(name = "currentPage") Integer currentPage,
                                        @RequestParam(name = "pageSize") Integer pageSize) {
        JSONObject object = logDataFeignClient.querySdOperLog(paramsDTO.getAppId(), paramsDTO.getOperUserId(), paramsDTO.getRequestUrl(), startTime, endTime, currentPage, pageSize);
        return new ResponseEntity<>(object, HttpStatus.OK);
    }

    @RequestMapping(value = "/querySdFileOperLog", method = RequestMethod.GET)
    public ResponseEntity<JSONObject> querySdFileOperLog(@ModelAttribute SdFileOperLog paramsDTO,
                                                         @RequestParam(name = "startTime") String startTime,
                                                         @RequestParam(name = "endTime") String endTime,
                                                            @RequestParam(name = "currentPage") Integer currentPage,
                                                            @RequestParam(name = "pageSize") Integer pageSize) {
        JSONObject object = logDataFeignClient.querySdFileOperLog(paramsDTO.getAppId(), paramsDTO.getOperUserId(), startTime, endTime, currentPage, pageSize);
        return new ResponseEntity<>(object, HttpStatus.OK);
    }

    @RequestMapping(value = "/querySdAuthChgLog", method = RequestMethod.GET)
    public ResponseEntity<JSONObject> querySdAuthChgLog(@ModelAttribute SdAuthChgLog paramsDTO,
                                                        @RequestParam(name = "startTime") String startTime,
                                                        @RequestParam(name = "endTime") String endTime,
                                                        @RequestParam(name = "currentPage") Integer currentPage,
                                                        @RequestParam(name = "pageSize") Integer pageSize) {
        JSONObject object = logDataFeignClient.querySdAuthChgLog(paramsDTO.getAppId(), paramsDTO.getOperUserId(),startTime, endTime, currentPage, pageSize);
        return new ResponseEntity<>(object, HttpStatus.OK);
    }
}
